package cn.jsj.finance.bank;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jsj.object.FrontWageInfo;
import cn.jsj.pojo.TblWageManage;
import cn.jsj.utils.SysLogger;

/**
 * 加载所有工资帐信息处理类
 * @author LI
 *
 */
 public class WageInfoRequest extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 	// 调试信息
		 	cn.jsj.utils.SysLogger.PrintInfo("加载所有工资帐信息！！！");

			//获得参数：1.第几条开始。2.一页显示几条
			int startNumb=Integer.parseInt(request.getParameter("start"));
			int totalNumb=Integer.parseInt(request.getParameter("limit"));
			//调试信息
			cn.jsj.utils.SysLogger.PrintInfo("start---->"+startNumb+"   total--------->"+totalNumb);

			//获得所有工资帐信息条数
			cn.jsj.dao.TblWageManageDAO twmd=new cn.jsj.dao.TblWageManageDAO();
			int wageInfoNumb=twmd.getWageInfoNumb();

			//工资信息队列
			java.util.List<TblWageManage> wageInfoList=new java.util.LinkedList<TblWageManage>();
			wageInfoList=twmd.getWageInfo(startNumb, totalNumb);

			//新建转化类对象
			 cn.jsj.object.rebuild.FrontWageInfoRebuild fwir=new cn.jsj.object.rebuild.FrontWageInfoRebuild();
			//转化成前台所需要的工资对象
			java.util.List<FrontWageInfo> frontWageInfoList=new java.util.LinkedList<FrontWageInfo>();
			//前台工资帐对象
			cn.jsj.object.FrontWageInfo fwi=new cn.jsj.object.FrontWageInfo();
			for(int i=0;i<wageInfoList.size();i++){
				fwi=fwir.rebuildWageInfo(wageInfoList.get(i));
				frontWageInfoList.add(fwi);
			}

			//转化为JSON型数据
			cn.jsj.utils.ProduceJsonData pjd=new cn.jsj.utils.ProduceJsonData();
			String jsonResult=pjd.jsonFromList(frontWageInfoList, wageInfoNumb);

			//调试信息
			SysLogger.PrintInfo(jsonResult);
			//输出到客户端
			java.io.PrintWriter pw=response.getWriter();
			pw.println(jsonResult);
			pw.flush();
			pw.close();




	}
}